﻿using MotionControl.Modules.PLC.Business;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MotionControl.Modules.PLC.Views
{
    /// <summary>
    /// Interaction logic for PLCView.xaml
    /// </summary>
    public partial class PLCView : UserControl
    {
        public PLCView()
        {
            InitializeComponent();
        }

        private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                var tb = (TextBox)sender;
                tb.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //221
            //var btn = (Button)sender;
            //var row = Grid.GetRow(btn);
            //if(btn.Content.ToString() == "JOG+" || btn.Content.ToString() == "JOG-")
            //    btn.IsEnabled = false;
            //for (int i = 0; i < AxisGrid.Children.Count; i++)
            //{
            //    var element = AxisGrid.Children[i];
            //    int elementRowIndex = (int)element.GetValue(Grid.RowProperty);
            //    if (elementRowIndex == row)
            //    {            
            //        if (element is Button otherBtn)
            //        {
            //            if (btn.Content.ToString() == "停止")
            //                otherBtn.IsEnabled = true;
            //            else if (btn.Content.ToString() == "JOG+")
            //            {
            //                if (otherBtn.Content.ToString() == "JOG-")
            //                    otherBtn.IsEnabled = false;
            //            }                      
            //        }
            //    }
            //}
        }

        private void Button_MouseDown(object sender, MouseButtonEventArgs e)
        {

        }

        private void Button_MouseUp(object sender, MouseButtonEventArgs e)
        {

        }
    }
}
